/**********************************************************
 * CheckProgramPermission.java.java
 * Created by Ashutosh
 * Last modified Date: Sep 18, 2008 10:46:12 AM by Ashutosh
 * Revision: <svn revision #>
 * Version : 0.1
 * Copyright (c) 2008 - 2009 cyberThink Infotech Pvt. Ltd., All rights reserved.
 **********************************************************/

package com.printeverywhere.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;

import com.printeverywhere.util.FileUtil;
import com.printeverywhere.util.SystemDir;

/**
 * The Class CheckProgramPermission.
 */
public class CheckProgramPermission extends AdminSystemTools implements ServletRequestAware{

	/** Logger for this class. */
	private static final Logger logger = Logger.getLogger(CheckProgramPermission.class);

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/** The request. */
	private HttpServletRequest request;

	/** The file list. */
	List<SystemDir> fileList;

	/**
	 * Gets the file list.
	 *
	 * @return the file list
	 */
	public List<SystemDir> getFileList() {
		return fileList;
	}

	/**
	 * Sets the file list.
	 *
	 * @param fileList the new file list
	 */
	public void setFileList(List<SystemDir> fileList) {
		this.fileList = fileList;
	}

	/* (non-Javadoc)
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	public String execute() throws Exception{
		if (logger.isDebugEnabled()) {
			logger.debug("execute() - start"); //$NON-NLS-1$
		}

		fileList=new ArrayList<SystemDir>();
		fileList = FileUtil.showFileAndDir(request.getRealPath(""), fileList);

		if (logger.isDebugEnabled()) {
			logger.debug("execute() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}

	/* (non-Javadoc)
	 * @see org.apache.struts2.interceptor.ServletRequestAware#setServletRequest(javax.servlet.http.HttpServletRequest)
	 */
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	/**
	 * Gets the request.
	 *
	 * @return the request
	 */
	public HttpServletRequest getRequest() {
		return request;
	}

	/**
	 * Sets the request.
	 *
	 * @param request the new request
	 */
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
}